/**
 * @author Tendo
 * @date 2021/7/15
 * @param {number[]} nums
 * @return {number[]}
 * @desc 双指针
 */
 const sortedSquares = (nums) => {
    let res = []
    for (let i = 0, j = nums.length - 1; i <= j;) {
      const left = Math.abs(nums[i])//获取绝对值
      const right = Math.abs(nums[j])
      if (right > left) {
        // push element to the front of the array
        res.unshift(right * right)
        j--
      } else {
        res.unshift(left * left)
        i++
      }
    }
    return res
}